#!/usr/bin/env python 
# -*- coding:utf-8 -*-
"""
@Time:2022/3/5 下午2:53"
@Author:lydia_liu"
@File:product_list_page.py
@function:
"""
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait

from litemallPrac.page.base_page import BasePage



class ProductListPage(BasePage):

    _product_listname = (By.XPATH,'//*[@class="el-table__body"]/tbody/tr[1]/td[3]/div')

    # 商品名称
    _product_name = (By.XPATH,'//*[@class="filter-container"]/div[3]/input',"商品名称0306")
    #查找按钮
    _button_search = (By.XPATH,'//span[contains(text(),"查找")]')
    #编辑按钮
    _button_edit = (By.XPATH,'//*[@class="el-table__body"]/tbody/tr[1]/td[12]//button[1]')


    #在商品列表页面
    def getname(self):

        wait = WebDriverWait(self.driver,10)

        element = wait.until(expected_conditions.visibility_of_element_located(self._product_listname)).text

        return element

    def search_product_name(self):
        # 输入商品名称
        self.sendkeys(*self._product_name)
        #点击查找按钮
        self.on_click(*self._button_search)

        return self.getname()

    def click_editbutton(self):
        #点击编辑按钮
        self.on_click(*self._button_edit)

        from litemallPrac.page.product_edit_page import ProductEdit

        return ProductEdit(self.driver)




